package com.lzb.findphone.utils;

import com.blankj.utilcode.util.GsonUtils;
import com.blankj.utilcode.util.SPUtils;
import com.google.gson.reflect.TypeToken;
import com.lzb.findphone.R;
import com.lzb.findphone.bean.SettingBean;


public class AppSpUtils {
    private static final String SP_NAME = "appCollSp";
    private static final SPUtils sSpUtils = SPUtils.getInstance(SP_NAME);

    public static void initSetting() {
        SettingBean settingBean = new SettingBean(R.raw.gou, 10 * 1000L, true, true, 1000L, 1000L);
        saveSetting(settingBean);
    }

    public static void saveSetting(SettingBean bean) {
        String json = GsonUtils.toJson(bean);
        sSpUtils.put(Key.key_piano_key_list, json);
    }

    public static SettingBean getSetting() {
        String json = sSpUtils.getString(Key.key_piano_key_list);
        return GsonUtils.fromJson(json, new TypeToken<SettingBean>() {
        }.getType());
    }

    interface Key {
        String key_piano_key_list = "key_setting_list";
    }
}